package com.backend.system.common;

import com.backend.system.util.StringUtil;
import org.slf4j.MDC;

/**
 * 日志ID
 *
 * @author backend-manage
 */
public class LogId {

    private LogId() {
    }

    public static void put(String logId) {
        MDC.put(StringConstant.LOG_ID, logId);
    }

    public static String get() {
        String logId = MDC.get(StringConstant.LOG_ID);
        if (logId == null) {
            logId = StringUtil.uuid();
            put(logId);
        }

        return logId;
    }

    public static void remove() {
        MDC.remove(StringConstant.LOG_ID);
    }
}
